< previous page page_275 next page >

Page 275
see whether the Save command button has already been toggled to Enabled. If it has, you know that the user has made changes and theres no need to call the ToggleButtons procedure to toggle the command buttons to become disabled. Youll learn more about the ToggleButtons procedure in the next section:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub TextChanged()
   If datEmployees.Recordset.EOF Or _
      datEmployees.Recordset.BOF Then
      ' Do Nothing
   Else
      If Not cmdSave.Enabled Then
         Call ToggleButtons
      End If
   End If
End Sub
Toggling the Command Buttons
Once the user enters the edit or add mode, youll need to turn off the New and Delete buttons so that the user doesnt try to add or delete records while editing data. In addition, youll need to enable the Save command button so that the user can save the changes just made. You should also disable the data list box and the data control so that the user cant move to a new record until he or she commits or cancels the changes just made. The ToggleButtons routine sets the Enabled property of each of these controls to the appropriate state.
EXERCISE
Adding the ToggleButtons procedure
1. Add a general form procedure called ToggleButtons, as follows:
Private Sub ToggleButtons()
If cmdClose.Caption = "&Close" Then
cmdClose.Caption = "&Cancel"
Else
cmdClose.Caption = "&Close"
End If
cmdSave.Enabled = Not cmdSave.Enabled
cmdNew.Enabled = Not cmdNew.Enabled
cmdDelete.Enabled = Not cmdDelete.Enabled
dlstEmps.Enabled = Not dlstEmps.Enabled
datEmployees.Enabled = Not datEmployees.Enabled
End Sub

 
< previous page page_275 next page >

If you like this book, buy it!